﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DP.Web.UI;
using System.Net;
using CRM.BLL;
using CRM.Entity;

namespace CRM.Web.RecordManage
{
    public partial class RecordDownLoad : Common.PageBase
    {
        public string FileUrl = "";

        private T_RECORD_BLL recordBll = new T_RECORD_BLL();

        protected override void OnInit(EventArgs e)
        {
            base.VerificationRight = false;
            base.OnInit(e);
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                try
                {
                    string inum = PageHelper.GetQueryString(this.Page, "INUM");
                    if (String.IsNullOrEmpty(inum))
                    {
                        return;
                    }

                    string virtualPath = "~/TempFilePath/RecordFile/" + inum + ".wav";

                    string filePath = Request.MapPath(virtualPath);
                    if (System.IO.File.Exists(filePath))
                    {
                        //FileUrl = virtualPath.Replace("~", "..");
                    }
                    else
                    {
                        recordBll.DownloadFile(inum, filePath);
                        //FileUrl = virtualPath.Replace("~", "..");
                    }
                    
                    //Response.Clear();
                    //Response.ContentType = "audio/x-wav";//'audio/x-wav'
                    Response.Redirect(virtualPath);
                }
                catch
                {
                    PageHelper.ShowMessage("录音文件不存在！");
                }

            }
        }
    }
}
